home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_02_10 / 2n10053a < prev    next >
Text File  |  1991-09-03  |  14KB  |  412 lines

  1. @cplus = //  VCR.CPP - VCR device driver class.<R>
  2. //      VCR::VCR - Constructor for VCR<R>
  3. //      VCR::~VCR - Destructor for VCR<R>
  4. //      VCR::SendCommand - Send command string to VCR<R>
  5. //      VCR::Stop - Puts the VCR into Stop mode.<R>
  6. //      VCR::Eject - Causes the tape to be ejected from the VCR.<R>
  7. //      VCR::Rewind - Places the VCR into full speed rewind.<R>
  8. //      VCR::FastForward - Places the VCR into full speed fast forward.<R>
  9. //      VCR::PlayFastReverse - Places the VCR into fast reverse play.<R>
  10. //      VCR::PlayFastForward - Places the VCR into fast forward play.<R>
  11. //      VCR::Still - Causes the VCR to Still on the current frame.<R>
  12. //      VCR::Record - Begin recording mode.<R>
  13. //      VCR::Play - Begins normal play mode.<R>
  14. //      VCR::ReversePlay - Begins normal reverse play mode;<R>
  15. //      VCR::StepForward - From a still frame, advance to next field.<R>
  16. //      VCR::StepReverse - From a still frame, step to previous field.<R>
  17. //      VCR::PowerToggle - Toggle VCR power.<R>
  18. <R>
  19. #include    "VCR.h"<R>
  20. <R>
  21. /******************************************************************<R>
  22. *   VCR::VCR - Constructor for VCR<R>
  23. *<R>
  24. *   Parameters:<R>
  25. *       int nNewPortAddress - default is address for COM1:<R>
  26. *<R>
  27. *   Class Variables Used:<R>
  28. *       SerialPort *spSerialPort;<R>
  29. *<R>
  30. *   Returns:<R>
  31. *       Nothing<R>
  32. *<R>
  33. *   Notes:<R>
  34. *       1.  Configures serial port to 9600 baud, 8 data bits,<R>
  35. *           no parity, and 1 stop bit.<R>
  36. *   Copyright:<R>
  37. *       Original code by William H. Roetzheim (619) 669-6970<R>
  38. *       Copyright (c) 1991 by William H. Roetzheim<R>
  39. *       All rights reserved.<R>
  40. *<R>
  41. **********************************************************************/<R>
  42. VCR::VCR (int nNewPortAddress)<R>
  43. {<R>
  44.     spSerialPort = new SerialPort (nNewPortAddress, "VCR");<R>
  45.     spSerialPort->>SetBaud (9600);<R>
  46.     spSerialPort->>SetBitsPerWord (8);<R>
  47.     spSerialPort->>SetStopBits (1);<R>
  48.     spSerialPort->>SetParity (NoParity);<R>
  49. }<R>
  50. <R>
  51. <R>
  52. /******************************************************************<R>
  53. *   VCR::~VCR - Destructor for VCR<R>
  54. *<R>
  55. *   Parameters:<R>
  56. *       None.<R>
  57. *<R>
  58. *   Class Variables Used:<R>
  59. *       Port *SerialPort
  60.  
  61. @cplus = *<R>
  62. **********************************************************************/<R>
  63. VCR::~VCR ()<R>
  64. {<R>
  65.     delete spSerialPort;<R>
  66. }<R>
  67. <R>
  68. <R>
  69. <R>
  70. /******************************************************************<R>
  71. *   VCR::SendCommand - Send command string to VCR<R>
  72. *<R>
  73. *   Parameters:<R>
  74. *       Str sCommandString - String to be output<R>
  75. *<R>
  76. *   Class Variables Used:<R>
  77. *       Port *SerialPort<R>
  78. *<R>
  79. **********************************************************************/<R>
  80. void VCR::SendCommand (Str sCommandString)<R>
  81. {<R>
  82.     // Send start of command string character<R>
  83.     spSerialPort->>OutChar (0x02);<R>
  84. <R>
  85.     // Send command string<R>
  86.     int     i;<R>
  87.     for (i = 0; i << sCommandString.Length (); i++)<R>
  88.     {<R>
  89.         spSerialPort->>OutChar (sCommandString.Slice (i));<R>
  90.     }<R>
  91. <R>
  92.     // Send end of command string character<R>
  93.     spSerialPort->>OutChar (0x03);<R>
  94. }<R>
  95. <R>
  96. <R>
  97. /******************************************************************<R>
  98. *   VCR::Stop - Puts the VCR into Stop mode.<R>
  99. *<R>
  100. *   Notes:<R>
  101. *       1.  This will abort any command in process, and stop<R>
  102. *           any tape motion.<R>
  103. *<R>
  104. *       2.  This command should not normally be used to terminate<R>
  105. *           an assembly or insert edit.  Stop will immediately<R>
  106. *           stop the VCR, preventing a clean edit transition.  Use<R>
  107. *           Still instead to allow the VCR to establish proper<R>
  108. *           sync at the edit out point.<R>
  109. *<R>
  110. *       3.  The tape is left loaded on the head to allow quick<R>
  111. *           resynchronization after a new play command.<R>
  112. *<R>
  113. *       4.  Maximum command duration is 300 ms.<R>
  114. *<R>
  115. *       5.  Audio and video are immediately placed into passthrough.<R>
  116. *<R>
  117. **********************************************************************/<R>
  118. void VCR::Stop (void)<R>
  119. {<R>
  120.     SendCommand ("A@@");
  121.  
  122. @cplus = }<R>
  123. <R>
  124. <R>
  125. /******************************************************************<R>
  126. *   VCR::Eject - Causes the tape to be ejected from the VCR<R>
  127. *<R>
  128. *   Notes:<R>
  129. *       1.  Reception of this command will abort any command<R>
  130. *           in process, and eject the tape.  If no tape is<R>
  131. *           in the VCR, the command has no effect.<R>
  132. *<R>
  133. *       2.  After a tape has been ejected, it can only be reloaded<R>
  134. *           into the VCR manually.<R>
  135. *<R>
  136. *       3.  Maximum command duration is 5 seconds.<R>
  137. *<R>
  138. *       4.  Audio and video are immediately placed into passthrough.<R>
  139. *<R>
  140. **********************************************************************/<R>
  141. void VCR::Eject (void)<R>
  142. {<R>
  143.     SendCommand ("A@A");<R>
  144. }<R>
  145. <R>
  146. <R>
  147. /******************************************************************<R>
  148. *   VCR::Rewind - Places the VCR into full speed rewind<R>
  149. *<R>
  150. *   Notes:<R>
  151. *       1.  This is the fastest way to position the tape in the<R>
  152. *           reverse direction.  No audio or video is output during<R>
  153. *           the rewind.<R>
  154. *<R>
  155. *       2.  This command cannot be used if high accuracy is required.<R>
  156. *           Since the tape is moved at high speed, minor errors in the<R>
  157. *           frame count will result every time this command is executed.<R>
  158. *           If high accuracy is required, the PlayFastReverse () command<R>
  159. *           must be used instead.<R>
  160. *<R>
  161. *       3.  Maximum command duration, 300 mSeconds to start rewinding.<R>
  162. *<R>
  163. *       4.  Audio and video are placed into passthrough.<R>
  164. *<R>
  165. **********************************************************************/<R>
  166. void VCR::Rewind (void)<R>
  167. {<R>
  168.     SendCommand ("A@B");<R>
  169. }<R>
  170. <R>
  171. <R>
  172. /******************************************************************<R>
  173. *   VCR::FastForward - Places the VCR into full speed fast forward<R>
  174. *<R>
  175. *   Notes:<R>
  176. *       1.  This is the fastest way to position the tape in the<R>
  177. *           forward direction.  No audio or video is output<R>
  178. *           during the fast forward.<R>
  179. *<R>
  180. *       2.  This command cannot be used if high accuracy is<R>
  181. *           required.  Since the tape is moved at high speed,
  182.  
  183. @cplus = *           minor errors in the frame count will result every time<R>
  184. *           this command is executed.  If high accuracy is required,<R>
  185. *           the PlayFastForward () command must be used instead.<R>
  186. *<R>
  187. *       3.  Maximum command duration is 300 mSeconds to begin fast<R>
  188. *           forwarding.<R>
  189. *<R>
  190. *       4.  Audio and video are placed in passthrough.<R>
  191. *<R>
  192. **********************************************************************/<R>
  193. void VCR::FastForward (void)<R>
  194. {<R>
  195.     SendCommand ("A@C");<R>
  196. }<R>
  197. <R>
  198. <R>
  199. /******************************************************************<R>
  200. *   VCR::PlayFastReverse - Places the VCR into fast reverse play<R>
  201. *<R>
  202. *   Notes:<R>
  203. *       1.  This mode moves the tape as fast as possible, while<R>
  204. *           still providing a video picture.  No audio is output<R>
  205. *           during the motion.<R>
  206. *<R>
  207. *       2.  This is the fastest way to move the tape in the reverse<R>
  208. *           direction and still maintain high tape count accuracy.<R>
  209. *<R>
  210. *       3.  The tape speed in this mode is 7X play (SP mode) or 21X<R>
  211. *           play (SLP mode).<R>
  212. *<R>
  213. *       4.  If very high accuracy is required, use of the CueToFrame ()<R>
  214. *           command is preferred, since abrupt tape stops may cause minor<R>
  215. *           count errors.  Allowing the tape to run off the beginning<R>
  216. *           may also cause errors in the tape count.<R>
  217. *<R>
  218. *       5.  Maximum command duration is 300 mSeconds to begin play.<R>
  219. *<R>
  220. *       6.  Video plays (with high speed noise bars), audio is muted.<R>
  221. *<R>
  222. **********************************************************************/<R>
  223. void VCR::PlayFastReverse (void)<R>
  224. {<R>
  225.     SendCommand ("A@D